package com.zhentao.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhentao.bean.QueryParam;
import com.zhentao.dao.ClassesDao;
import com.zhentao.dao.StudentDao;
import com.zhentao.pojo.Classes;
import com.zhentao.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentImpI implements StudentService{
    @Autowired
    private StudentDao studentDao;
    @Autowired
    private ClassesDao classesDao;
    @Override
    public PageInfo<Student> findPage(int currentPage, int pageSize, QueryParam queryParam) {
        PageHelper.startPage(currentPage,pageSize);
        List<Student> all = studentDao.All(queryParam);
        PageInfo<Student> pageInfo=new PageInfo<>(all,5);
        return pageInfo;
    }

    @Override
    public void insert(Student student,Classes classes) {
        classesDao.insert(classes);
        Integer cid = classes.getCid();
        student.setCid(cid);
        studentDao.insert(student);
    }


}
